import { Column, Entity, JoinColumn, ManyToOne } from 'typeorm'
import { CommonEntity } from '~/common/entity/common.entity'
import { CUserStatus } from '../constant'
import { CUserEntity } from './user.entity'

@Entity({ name: 'c_user_history' })
export class CUserHistoryEntity extends CommonEntity {
  @Column({ name: 'user_id', comment: '关联的用户ID' })
  userId: number

  @ManyToOne(() => CUserEntity, { createForeignKeyConstraints: false })
  @JoinColumn({ name: 'user_id' })
  user: CUserEntity

  @Column({ name: 'editor_id', comment: '编辑者ID' })
  editorId: number

  @Column({ name: 'editor_name', comment: '编辑者姓名', default: '' })
  editorName: string

  @Column({ name: 'status_before', comment: '编辑前的用户阶段', type: 'int', nullable: true })
  statusBefore: CUserStatus

  @Column({ name: 'status_after', comment: '编辑后的用户阶段', type: 'int' })
  statusAfter: CUserStatus

  @Column({ name: 'mark_before', comment: '编辑前的备注', type: 'text', nullable: true })
  markBefore: string

  @Column({ name: 'mark_after', comment: '编辑后的备注', type: 'text' })
  markAfter: string
  
  @Column({ comment: '其他修改内容摘要', type: 'text', nullable: true })
  changes: string
} 